package com.qxzn.app.medicalhealth.adapter;

import android.app.Activity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.github.jdsjlzx.interfaces.OnItemClickListener;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.qxzn.app.bean.RobotDeviceListBean;
import com.qxzn.app.medicalhealth.R;
import com.qxzn.app.medicalhealth.R2;
import com.qxzn.app.util.AppUtil;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MedicalDeviceAdapter extends RecyclerView.Adapter<MedicalDeviceAdapter.ViewHolder> {

    private Activity activity;
    private List<RobotDeviceListBean.DataBean> dataList;
    private RobotDeviceListBean.DataBean item;

    public MedicalDeviceAdapter(Activity activity, List dataList) {
        this.activity = activity;
        this.dataList = dataList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(activity).inflate(R.layout.item_medical_device, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        item = dataList.get(position);
        MedicalDeviceSubAdapter adapter = new MedicalDeviceSubAdapter(activity, dataList);
//        LRecyclerViewAdapter recyclerViewAdapter = new LRecyclerViewAdapter(adapter);
        holder.lrvMedicalDeviceSub.setAdapter(adapter);
//        recyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
//            @Override
//            public void onItemClick(View view, int position) {
//                AppUtil.showLog("点击位置：" + position);
//            }
//        });
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R2.id.tv_title)
        TextView tvTitle;
        @BindView(R2.id.lrv_medical_device_sub)
        RecyclerView lrvMedicalDeviceSub;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
            lrvMedicalDeviceSub.setLayoutManager(new GridLayoutManager(view.getContext(), 3));
//            lrvMedicalDeviceSub.setPullRefreshEnabled(false);
        }
    }
}
